package button;

import java.awt.Button;
import java.awt.Image;
import java.awt.Point;

public abstract class ActionButton extends Button {
	public abstract Image getImage();
	
	public DragStatus status = DragStatus.Ready;
	
	public Point imagePosition = new Point(0, 0),  // 图片的当前位置
			 
            imageStartposition = new Point(0, 0);                     // 每次拖拽开始时鼠标的位置

	public Point mouseStartposition;

	public enum DragStatus {
        Ready, Dragging
    }
	/**
     * 移动图片。实际上画图工作在 paintComponent() 中进行，这里只是计算图片位置，然后调用该方法。
     *
     * @param point 当前的鼠标位置
     */
    private void moveImage(Point point) {
        // 图片的当前位置等于图片的起始位置加上鼠标位置的偏移量。
        imagePosition.setLocation(
                imageStartposition.getX() + (point.getX() - mouseStartposition.getX()),
                imageStartposition.getY() + (point.getY() - mouseStartposition.getY())
        );
        repaint();
    }
	public Point getImagePosition() {
		return imagePosition;
	}
	public void setImagePosition(Point imagePosition) {
		this.imagePosition = imagePosition;
	}
	public Point getImageStartposition() {
		return imageStartposition;
	}
	public void setImageStartposition(Point imageStartposition) {
		this.imageStartposition = imageStartposition;
	}
	public Point getMouseStartposition() {
		return mouseStartposition;
	}
	public void setMouseStartposition(Point mouseStartposition) {
		this.mouseStartposition = mouseStartposition;
	}
	public DragStatus getStatus() {
		return status;
	}
	public void setStatus(DragStatus status) {
		this.status = status;
	}
}
